<template>
	<view class="index">
		<view class="list-wrapper">
			<view class="item-wrapper" v-for="(item,index) in list" :key="index">
				<view class="title-wrapper">
					<image src="../static/image/wxpay.png" mode="widthFix" class="icon"></image>
					<view class="title">
						<text>微信收款账号</text>
						<text v-if="item.status === 1">（当前账号）</text>
						<text v-else-if="item.status === 2">（已弃用）</text>
						<text v-else-if="item.status === 0">（已冻结）</text>
					</view>
					<view class="status">
						<text v-if="item.applyStatus === 'FINISH'" style="color: #0E932E;">已开通</text>
						<text v-else-if="item.applyStatus === 'REJECTED' || item.applyStatus === 'FROZEN'"
							style="color: red;">{{ wxPayStatusEnum[item.applyStatus] }}</text>
						<text v-else>{{ wxPayStatusEnum[item.applyStatus] }}</text>
					</view>
				</view>
				<view class="info-wrapper">
					<view class="item">
						开户名称：{{ item.managerName }}
					</view>
					<view class="item">
						银行卡：{{ item.bankCode }}
					</view>
					<view class="item">
						开户行：{{ item.bankName }}
					</view>
				</view>
				<view class="btn" v-if="item.applyStatus === 'FINISH'" @click="confirm(item)">
					查看该账号
				</view>
			</view>
		</view>
		<!-- <view class="nodata-wrapper" v-if="!list.length">
			<image src="../static/image/nocustomer.png" class="icon" mode="widthFix"></image>
			<view>暂无收款账号</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					status: 1,
					applyStatus: 'FINISH',
					managerName: '上海好帮科技有限公司',
					bankCode: '6288 8833 22223 23223 22',
					bankName: '中国农业银行'
				}],
				wxPayStatusEnum: {
					'CHECKING': '资料校验中',
					'ACCOUNT_NEED_VERIFY': '待账户验证',
					'AUDITING': '审核中',
					'REJECTED': '已驳回',
					'NEED_SIGN': '待签约',
					'FINISH': '已开通',
					'FROZEN': '已冻结',
					'CANCELED': '已作废',
				},
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo
			}
		},
		mounted() {
			//this.getList()
		},
		methods: {
			async getList() {
				const data = await this.$api.get('/clz-portal/merchant-apply/list', {
					orgId: this.userInfo.marketing.orgId
				}, false)
				if (data.code === 200) {
					this.list = data.data.filter(item => item.applyStatus === 'FINISH');
				}
			},
			confirm(item) {
				// var pages = getCurrentPages();
				// var prevPage = pages[pages.length - 2];
				// if (prevPage == undefined || prevPage == null) return;
				// prevPage.$vm.doSearch(item);
				// uni.navigateBack();
			}
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100%;
		overflow: auto;
		padding: 0 20upx;

		.item-wrapper {
			margin-top: 20upx;
			border-radius: 20upx;
			background-color: #ffffff;
			padding: 30upx;

			.title-wrapper {
				display: flex;
				align-items: center;

				.icon {
					width: 46upx;
					margin-right: 10upx;
				}

				.title {
					font-size: 32upx;
					font-weight: bold;
					flex: 1;
				}

				.status {
					font-size: 28upx;
					color: #454545;
				}
			}

			.info-wrapper {
				margin: 0 20upx;

				.item {
					font-size: 30upx;
					color: #787878;
					margin-top: 10upx;
				}
			}

			.btn {
				margin: 30upx auto 0 auto;
				width: 400upx;
				height: 74upx;
				border-radius: 50upx;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #ffffff;
				background-color: #0E932E;
				font-size: 32upx;
			}
		}

		.nodata-wrapper {
			position: absolute;
			left: 50%;
			top: 40%;
			transform: translate(-50%, -50%);
			color: #555555;
			display: flex;
			flex-direction: column;
			align-items: center;

			.icon {
				width: 296upx;
			}
		}
	}
</style>